package com.ruoyi.rocky.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.rocky.domain.PcStoreProject;
import com.ruoyi.rocky.service.PcStoreProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 店铺服务项目Controller
 * @date 2024-04-25
 */
@RestController
@RequestMapping("/pcStoreProject")
@Api(tags = "服务管理")
public class PcStoreProjectController extends BaseController {
    @Autowired
    private PcStoreProjectService pcStoreProjectService;

    /**
     * 查询店铺服务项目列表
     */
    @ApiOperation(value = "查询店铺服务项目列表")
    @GetMapping("/list")
    public TableDataInfo list(PcStoreProject pcStoreProject) {
        startPage();
        List<PcStoreProject> list = pcStoreProjectService.selectPcStoreProjectList(pcStoreProject);
        return getDataTable(list);
    }

//    /**
//     * 导出店铺服务项目列表
//     */
//    @ApiOperation(value = "导出店铺服务项目列表")
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, PcStoreProject pcStoreProject) {
//        List<PcStoreProject> list = pcStoreProjectService.selectPcStoreProjectList(pcStoreProject);
//        ExcelUtil<PcStoreProject> util = new ExcelUtil<PcStoreProject>(PcStoreProject.class);
//        util.exportExcel(response, list, "店铺服务项目数据");
//    }

    /**
     * 根据店铺id查询服务项目
     */
    @ApiOperation(value = "根据店铺id查询服务项目")
    @GetMapping(value = "/selectById/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(pcStoreProjectService.selectPcStoreProjectById(id));
    }

    /**
     * 新增店铺服务项目
     */
    @ApiOperation(value = "新增店铺服务项目")
    @PostMapping("/add")
    public R add(@RequestBody PcStoreProject pcStoreProject) {
        return R.ok(pcStoreProjectService.insertPcStoreProject(pcStoreProject));
    }

    /**
     * 修改店铺服务项目
     */
    @ApiOperation(value = "修改店铺服务项目")
    @PutMapping("/edit")
    public R edit(@RequestBody PcStoreProject pcStoreProject) {
        return R.ok(pcStoreProjectService.updatePcStoreProject(pcStoreProject));
    }

    /**
     * 删除店铺服务项目
     */
    @ApiOperation(value = "删除店铺服务项目")
    @DeleteMapping("/delete/{ids}")
    public R remove(@PathVariable Long[] ids) {
        return R.ok(pcStoreProjectService.deletePcStoreProjectByIds(ids));
    }
}
